package com.xqls.quaz;



import com.xqls.dal.model.*;
import com.xqls.service.*;
import com.xqls.util.ContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.concurrent.Callable;

/**
 * Created by hdg on 2017/7/3.
 */
public class    RealdataRunAble   {


    private static final Logger LOG = LoggerFactory
            .getLogger(RealdataRunAble.class);

    DischargeRealdataRecordService dischargeRealdataRecordService = (DischargeRealdataRecordService) ContextUtil
            .getBean(DischargeRealdataRecordService.class);

    DischargeRealdataService dischargeRealdataService = (DischargeRealdataService) ContextUtil
            .getBean(DischargeRealdataService.class);

    IntakeRealdataRecordService intakeRealdataRecordService = (IntakeRealdataRecordService) ContextUtil
            .getBean(IntakeRealdataRecordService.class);

    PublicStormwaterRealdataRecordService publicStormwaterRealdataRecordService = (PublicStormwaterRealdataRecordService) ContextUtil
            .getBean(PublicStormwaterRealdataRecordService.class);

    RainwaterDischargeRealdataRecordService rainwaterDischargeRealdataRecordService = (RainwaterDischargeRealdataRecordService) ContextUtil
            .getBean(RainwaterDischargeRealdataRecordService.class);

    RainwaterDischargeRealdataService rainwaterDischargeRealdataService = (RainwaterDischargeRealdataService) ContextUtil
            .getBean(RainwaterDischargeRealdataService.class);

    PublicStormwaterRealdataService publicStormwaterRealdataService = (PublicStormwaterRealdataService) ContextUtil
            .getBean(PublicStormwaterRealdataService.class);

    IntakeRealdataService intakeRealdataService = (IntakeRealdataService) ContextUtil
            .getBean(IntakeRealdataService.class);

    FluggasDischargeRealdataService fluggasDischargeRealdataService = (FluggasDischargeRealdataService) ContextUtil
            .getBean(FluggasDischargeRealdataService.class);

    FluggasDischargeMimRecordService fluggasDischargeMimRecordService = (FluggasDischargeMimRecordService) ContextUtil
            .getBean(FluggasDischargeMimRecordService.class);

    public Void call() {


            fluggasDischargeRealdataRecordinsert();
            dischargeRealdataRecordinsert();
            intakeRealdataRecordinsert();
            publicStormwaterRealdataRecordinsert();
            rainwaterDischargeRealdataRecordinsert();


       return  null;
    }

    public void dischargeRealdataRecordinsert() {
        List<DischargeRealdataRecord> recordList = new ArrayList<DischargeRealdataRecord>();
        List<DischargeRealdata> dischargeList = dischargeRealdataService.selectDischarge();
        Date systime = new Date();
        int recordNo = dischargeRealdataRecordService.selectId();
        if (dischargeList != null) {
            for (int i = 0; i < dischargeList.size(); i++) {
                recordNo += 1;
                DischargeRealdataRecord DischargeRealdataRecord = new DischargeRealdataRecord();
                DischargeRealdataRecord.setRecordNo(recordNo);
                DischargeRealdataRecord.setRealdataNo(dischargeList.get(i).getRealdataNo());
                DischargeRealdataRecord.setDeviceNo(dischargeList.get(i).getDeviceNo());
                DischargeRealdataRecord.setNetwork(dischargeList.get(i).getNetwork());
                DischargeRealdataRecord.setInstantaneousFlow(dischargeList.get(i).getInstantaneousFlow());
                DischargeRealdataRecord.setCumulativeFlow(dischargeList.get(i).getCumulativeFlow());
                DischargeRealdataRecord.setValveState(dischargeList.get(i).getValveState());
                DischargeRealdataRecord.setValveSetting(dischargeList.get(i).getValveSetting());
                DischargeRealdataRecord.setSamplingState(dischargeList.get(i).getSamplingState());
                DischargeRealdataRecord.setSampleRetention(dischargeList.get(i).getSampleRetention());
                DischargeRealdataRecord.setInlet(dischargeList.get(i).getInlet());
                DischargeRealdataRecord.setInstrument(dischargeList.get(i).getInstrument());
                DischargeRealdataRecord.setPowerSupply(dischargeList.get(i).getPowerSupply());
                DischargeRealdataRecord.setDrainLevel(dischargeList.get(i).getDrainLevel());
                DischargeRealdataRecord.setCod(dischargeList.get(i).getCod());
                DischargeRealdataRecord.setPh(dischargeList.get(i).getPh());
                DischargeRealdataRecord.setPumpCurrent(dischargeList.get(i).getPumpCurrent());
                DischargeRealdataRecord.setBottleNo(dischargeList.get(i).getBottleNo());
                DischargeRealdataRecord.setSs(dischargeList.get(i).getSs());
                DischargeRealdataRecord.setNh3(dischargeList.get(i).getNh3());
                DischargeRealdataRecord.setRealTemperature(dischargeList.get(i).getRealTemperature());
                DischargeRealdataRecord.setBottleNumber(dischargeList.get(i).getBottleNumber());
                DischargeRealdataRecord.setSamplingTemperature(dischargeList.get(i).getSamplingTemperature());
                DischargeRealdataRecord.setIceboxTemperature(dischargeList.get(i).getIceboxTemperature());
                DischargeRealdataRecord.setRecordingTime(systime);
                recordList.add(DischargeRealdataRecord);
            }
            dischargeRealdataRecordService.insertList(recordList);
        }

    }

    public void intakeRealdataRecordinsert() {
        List<IntakeRealdataRecord> recordList = new ArrayList<IntakeRealdataRecord>();
        List<IntakeRealdata> intakeList = intakeRealdataService.selectintake();
        Date systime = new Date();
        int recordNo = intakeRealdataRecordService.selectId();
        if (intakeList != null) {
            for (int i = 0; i < intakeList.size(); i++) {
                recordNo += 1;
                IntakeRealdataRecord IntakeRealdataRecord = new IntakeRealdataRecord();
                IntakeRealdataRecord.setRecordNo(recordNo);
                IntakeRealdataRecord.setRealdataNo(intakeList.get(i).getRealdataNo());
                IntakeRealdataRecord.setDeviceNo(intakeList.get(i).getDeviceNo());
                IntakeRealdataRecord.setNetwork(intakeList.get(i).getNetwork());
                IntakeRealdataRecord.setInstantaneousFlow(intakeList.get(i).getInstantaneousFlow());
                IntakeRealdataRecord.setCumulativeFlow(intakeList.get(i).getCumulativeFlow());
                IntakeRealdataRecord.setPowerSupply(intakeList.get(i).getPowerSupply());
                IntakeRealdataRecord.setRecordingTime(systime);
                recordList.add(IntakeRealdataRecord);
            }
            intakeRealdataRecordService.insertList(recordList);
        }
    }

    public void publicStormwaterRealdataRecordinsert() {
        List<PublicStormwaterRealdataRecord> recordList = new ArrayList<PublicStormwaterRealdataRecord>();
        List<PublicStormwaterRealdata> stormwaterList = publicStormwaterRealdataService.selectPublic();
        Date systime = new Date();
        int recordNo = publicStormwaterRealdataRecordService.selectId();
        if (stormwaterList != null) {
            for (int i = 0; i < stormwaterList.size(); i++) {
                recordNo += 1;
                PublicStormwaterRealdataRecord PublicStormwaterRealdataRecord = new PublicStormwaterRealdataRecord();
                PublicStormwaterRealdataRecord.setRecordNo(recordNo);
                PublicStormwaterRealdataRecord.setRealdataNo(stormwaterList.get(i).getRealdataNo());
                PublicStormwaterRealdataRecord.setDeviceNo(stormwaterList.get(i).getDeviceNo());
                PublicStormwaterRealdataRecord.setNetwork(stormwaterList.get(i).getNetwork());
                PublicStormwaterRealdataRecord.setState(stormwaterList.get(i).getState());
                PublicStormwaterRealdataRecord.setInstantaneousFlow(stormwaterList.get(i).getInstantaneousFlow());
                PublicStormwaterRealdataRecord.setCumulativeFlow(stormwaterList.get(i).getCumulativeFlow());
                PublicStormwaterRealdataRecord.setSampleRetention(stormwaterList.get(i).getSampleRetention());
                PublicStormwaterRealdataRecord.setInlet(stormwaterList.get(i).getInlet());
                PublicStormwaterRealdataRecord.setInstrument(stormwaterList.get(i).getInstrument());
                PublicStormwaterRealdataRecord.setPowerSupply(stormwaterList.get(i).getPowerSupply());
                PublicStormwaterRealdataRecord.setDrainLevel(stormwaterList.get(i).getDrainLevel());
                PublicStormwaterRealdataRecord.setCod(stormwaterList.get(i).getCod());
                PublicStormwaterRealdataRecord.setPh(stormwaterList.get(i).getPh());
                PublicStormwaterRealdataRecord.setPumpCurrent(stormwaterList.get(i).getPumpCurrent());
                PublicStormwaterRealdataRecord.setBottleNo(stormwaterList.get(i).getBottleNo());
                PublicStormwaterRealdataRecord.setSs(stormwaterList.get(i).getSs());
                PublicStormwaterRealdataRecord.setNh3(stormwaterList.get(i).getNh3());
                PublicStormwaterRealdataRecord.setRealTemperature(stormwaterList.get(i).getRealTemperature());
                PublicStormwaterRealdataRecord.setBottleNumber(stormwaterList.get(i).getBottleNumber());
                PublicStormwaterRealdataRecord.setSamplingTemperature(stormwaterList.get(i).getSamplingTemperature());
                PublicStormwaterRealdataRecord.setIceboxTemperature(stormwaterList.get(i).getIceboxTemperature());
                PublicStormwaterRealdataRecord.setRecordingTime(systime);
                PublicStormwaterRealdataRecord.setEmissionWhere(stormwaterList.get(i).getIceboxTemperature());
                recordList.add(PublicStormwaterRealdataRecord);
            }
            publicStormwaterRealdataRecordService.insertList(recordList);
        }
    }

    public void rainwaterDischargeRealdataRecordinsert() {
        List<RainwaterDischargeRealdataRecord> recordList = new ArrayList<RainwaterDischargeRealdataRecord>();
        List<RainwaterDischargeRealdata> rainwaterList = rainwaterDischargeRealdataService.selectRainwater();
        Date systime = new Date();
        int recordNo = rainwaterDischargeRealdataRecordService.selectId();
        if (rainwaterList != null) {
            for (int i = 0; i < rainwaterList.size(); i++) {
                recordNo += 1;
                RainwaterDischargeRealdataRecord RainwaterDischargeRealdataRecord = new RainwaterDischargeRealdataRecord();
                RainwaterDischargeRealdataRecord.setRecordNo(recordNo);
                RainwaterDischargeRealdataRecord.setRealdataNo(rainwaterList.get(i).getRealdataNo());
                RainwaterDischargeRealdataRecord.setDeviceNo(rainwaterList.get(i).getDeviceNo());
                RainwaterDischargeRealdataRecord.setNetwork(rainwaterList.get(i).getNetwork());
                RainwaterDischargeRealdataRecord.setInstantaneousFlow(rainwaterList.get(i).getInstantaneousFlow());
                RainwaterDischargeRealdataRecord.setCumulativeFlow(rainwaterList.get(i).getCumulativeFlow());
                RainwaterDischargeRealdataRecord.setValveSetting(rainwaterList.get(i).getValveSetting());
                RainwaterDischargeRealdataRecord.setSamplingState(rainwaterList.get(i).getSamplingState());
                RainwaterDischargeRealdataRecord.setSampleRetention(rainwaterList.get(i).getSampleRetention());
                RainwaterDischargeRealdataRecord.setInlet(rainwaterList.get(i).getInlet());
                RainwaterDischargeRealdataRecord.setInstrument(rainwaterList.get(i).getInstrument());
                RainwaterDischargeRealdataRecord.setPowerSupply(rainwaterList.get(i).getPowerSupply());
                RainwaterDischargeRealdataRecord.setDrainLevel(rainwaterList.get(i).getDrainLevel());
                RainwaterDischargeRealdataRecord.setCod(rainwaterList.get(i).getCod());
                RainwaterDischargeRealdataRecord.setPh(rainwaterList.get(i).getPh());
                RainwaterDischargeRealdataRecord.setPumpCurrent(rainwaterList.get(i).getPumpCurrent());
                RainwaterDischargeRealdataRecord.setBottleNo(rainwaterList.get(i).getBottleNo());
                RainwaterDischargeRealdataRecord.setSs(rainwaterList.get(i).getSs());
                RainwaterDischargeRealdataRecord.setNh3(rainwaterList.get(i).getNh3());
                RainwaterDischargeRealdataRecord.setRealTemperature(rainwaterList.get(i).getRealTemperature());
                RainwaterDischargeRealdataRecord.setBottleNumber(rainwaterList.get(i).getBottleNumber());
                RainwaterDischargeRealdataRecord.setSamplingTemperature(rainwaterList.get(i).getSamplingTemperature());
                RainwaterDischargeRealdataRecord.setIceboxTemperature(rainwaterList.get(i).getIceboxTemperature());
                RainwaterDischargeRealdataRecord.setRecordingTime(systime);
                RainwaterDischargeRealdataRecord.setValveRealtime(rainwaterList.get(i).getValveRealtime());
                recordList.add(RainwaterDischargeRealdataRecord);
            }
            rainwaterDischargeRealdataRecordService.insertList(recordList);
        }
    }

    public void fluggasDischargeRealdataRecordinsert() {
        List<FluggasDischargeMimRecord> recordList = new ArrayList<FluggasDischargeMimRecord>();
        List<FluggasDischargeRealdata> fluggasList = fluggasDischargeRealdataService.selectFluggas();
        Date systime = new Date();
        int recordNo = fluggasDischargeMimRecordService.selectId();
        if (fluggasList != null) {
            for (int i = 0; i < fluggasList.size(); i++) {
                recordNo += 1;
                FluggasDischargeMimRecord FluggasDischargeMimRecord = new FluggasDischargeMimRecord();
                FluggasDischargeMimRecord.setRecordNo(recordNo);
                FluggasDischargeMimRecord.setDeviceNo(fluggasList.get(i).getDeviceNo());
                FluggasDischargeMimRecord.setO2Content(fluggasList.get(i).getO2Content());
                FluggasDischargeMimRecord.setSmokeVelocity(fluggasList.get(i).getSmokeVelocity());
                FluggasDischargeMimRecord.setSmokeTemperature(fluggasList.get(i).getSmokeTemperature());
                FluggasDischargeMimRecord.setSmokeDynamicPressure(fluggasList.get(i).getSmokeDynamicPressure());
                FluggasDischargeMimRecord.setSmokeHumidity(fluggasList.get(i).getSmokeHumidity());
                FluggasDischargeMimRecord.setSmokePressure(fluggasList.get(i).getSmokePressure());
                FluggasDischargeMimRecord.setSmoke(fluggasList.get(i).getSmoke());
                FluggasDischargeMimRecord.setSo2(fluggasList.get(i).getSo2());
                FluggasDischargeMimRecord.setNo2(fluggasList.get(i).getNo2());
                FluggasDischargeMimRecord.setCo(fluggasList.get(i).getCo());
                FluggasDischargeMimRecord.setH2s(fluggasList.get(i).getH2s());
                FluggasDischargeMimRecord.setHcl(fluggasList.get(i).getHcl());
                FluggasDischargeMimRecord.setNh3(fluggasList.get(i).getNh3());
                FluggasDischargeMimRecord.setCl2(fluggasList.get(i).getCl2());
                FluggasDischargeMimRecord.setCs2(fluggasList.get(i).getCs2());
                FluggasDischargeMimRecord.setBenzeneSeries(fluggasList.get(i).getBenzeneSeries());
                FluggasDischargeMimRecord.setToluene(fluggasList.get(i).getToluene());
                FluggasDischargeMimRecord.setRecordingTime(systime);
                FluggasDischargeMimRecord.setXylene(fluggasList.get(i).getXylene());
                FluggasDischargeMimRecord.setFormaldehyde(fluggasList.get(i).getFormaldehyde());
                FluggasDischargeMimRecord.setPhenols(fluggasList.get(i).getPhenols());
                FluggasDischargeMimRecord.setMethanol(fluggasList.get(i).getMethanol());
                FluggasDischargeMimRecord.setVinylChloride(fluggasList.get(i).getVinylChloride());
                FluggasDischargeMimRecord.setCo2(fluggasList.get(i).getCo2());

                recordList.add(FluggasDischargeMimRecord);
            }
            fluggasDischargeMimRecordService.insertList(recordList);
        }
    }
}
